(async function(){
    let business = cookie.get('business') ? JSON.parse(cookie.get('business')) : {};

    if(!business || JSON.stringify(business) === '{}')
    {
        mui.toast('请先登录');

        setTimeout(() => {
            location.href = 'login.html';
        },2000);

        return;
    }

    let id = business.id ?? 0;
    let mobile = business.mobile ?? '';

    let data = {
        id,
        mobile
    }

    let result = await POST({
        url:'business/check',
        params:data
    });

    if(result && result.code === 0)
    {
        mui.toast('非法登录');

        cookie.remove('business');

        setTimeout(() => {
            location.href = 'login.html';
        },2000);

        return;
    }

    cookie.set('business',JSON.stringify(result.data));
})();
